package com.example.spring_java_oj.mapper;

import com.example.spring_java_oj.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserInfoMapper {
    /**
     * 根据用户名, 查询用户信息
     */
    @Select("select * from user where username =#{userName}")
    UserInfo queryByName(String userName);

    /**
     * 根据用户ID, 查询用户信息
     */
    @Select("select * from user where id=#{id}")
    UserInfo queryById(Integer id);

    @Insert("insert into user values(null, #{username}, #{password}, 0)")
    Integer register(@Param("username") String username, @Param("password") String password);
}
